<h1>New borrowing</h1>

<% form_tag :action => 'create' do %>
<%= error_messages_for 'borrowing' %>

<!--[form:borrowing]-->
<p><label for="borrowing_book">Book</label><br/>
<% if @borrowing.book_id.nil? -%>
<%= select("borrowing", "book_id", Book.find(:all, :conditions => ["state =?", Book::STATE_AVAILABLE], :order => "title").collect{|b| [b.title, b.id]}) %></p>
<% else -%>
<%=h @borrowing.book.title -%>
<%= hidden_field 'borrowing', 'book_id' -%>
<% end %>
<p><label for="borrowing_user">User</label><br/>
<% if @borrowing.user_id.nil? -%>
<%= select("borrowing", "user_id", User.find_all.collect {|u| [u.surname + ' ' + u.first_name, u.id]}) %></p>
<% else -%>
<%=h @borrowing.user.surname + ' ' + @borrowing.user.first_name -%>
<%= hidden_field 'borrowing', 'user_id' -%>
<% end %>

<p><label for="borrowing_borrowing_date">Borrowing date</label><br/>
<%= date_select 'borrowing', 'borrowing_date'  %></p>
<!--[eoform:borrowing]-->

  <%= submit_tag "Create" %>
<% end %>

<%= link_to 'Back', :action => 'list' %>
